Skip to content

Draw QC graphs and score cards with d3 instead of Protovis - #55

Merged
kf8a merged 2 commits into
masterfrom
feature/d3-graphs
Nov 3, 2026
Merged

kf8a merged 2 commits into
masterfrom
feature/d3-graphs

Conversation

@kf8a

@kf8a kf8a commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Summary

Replaces the Protovis-era graph scripts with Stimulus controllers that draw with d3, and deletes the old scripts. (The branch dates from 2026-10-25; master has been merged into it and the two conflicts resolved.)

Removed (about 15,700 lines):

  • app/assets/javascripts/protovis-d3.2.js (the Protovis library)
  • app/assets/javascripts/proto-graphs.js
  • app/assets/javascripts/scores.js
  • the matching link_directory line in the asset manifest and the legacy script loads in application.js

Added:

  • qc_graph_controller.js: draws a QC graph from a visualization's JSON (dot graphs and line graphs, with axes and the y-axis label)
  • score_card_controller.js: draws a datatable's yearly scores
  • vendor/javascript/d3.js: d3 7.9.0 as one ES module, pinned in the importmap (no CDN)
  • spec/requests/d3_graphs_spec.rb

The QC page and score card views now hand each controller its data through data-* values instead of inline script.

Merge with master

Two conflicts, both keeping both sides:

  • visualizations_controller.rb: the class comment now says it serves the d3 graphs' data and that the data follows the datatable's download rules (PR Apply datatable download rules to visualization data #36).
  • controllers/index.js: registers qc-graph and score-card alongside the tree controller added since.

Testing

  • spec/requests/d3_graphs_spec.rb: each QC graph points at its visualization's data, type and label; visualization rows are served as JSON; the score card gets its yearly scores, or an empty list; the importmap loads d3 and none of the old scripts.
  • Full suite: 312 examples, 0 failures, 3 pending. Run against the schema.rb before 7f502da, since master's current schema can't be loaded into a fresh database (see the structure.sql PR Dump the database schema as db/structure.sql #53). zeitwerk:check passes.
  • Checked in a browser (local run, test data, without the WordPress header): the QC page draws a dot graph with 302 points, axes, month labels and the y-axis label; the score card draws its yearly circles. No JavaScript errors from these controllers.
  • Not checked against real production data or older browsers.

Related

Removes the last scripts that needed jQuery-era Protovis; jQuery itself is still loaded for four .js.erb templates (see the dead-code checklist, docs/dead-code-checklist.md on docs/dead-code-checklist).


Generated by Claude Code

The QC graphs ran on Protovis plus jQuery, and the score cards called the
d3 v3 API without d3 ever being loaded, so they never rendered. Both are
now Stimulus controllers on a vendored d3 7.9.0 ES module:

- qc-graph fetches a visualization's JSON and draws its dot, area, bar,
  bubble or category-bubble graph, with a nearest-point hover label
- score-card draws one circle per year from the datatable's scores

Remove protovis-d3.2.js, proto-graphs.js, scores.js and the legacy
importmap pins that served app/assets/javascripts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016AR3uoZS1uCC8hXmojk3K7
# Conflicts:
#	app/controllers/visualizations_controller.rb
#	app/javascript/controllers/index.js
@kf8a
kf8a merged commit b73e80b into master Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants